﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Entity;
using BusinessObject;

namespace GreenLife.Admin
{
    public partial class ChinhSuaHoaDon : System.Web.UI.Page
    {
        DataSet ds;
        Orders o;
        OrderBO oBO = new OrderBO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                selectOrderById();
            }
        }

        public void selectOrderById()
        {
            o = new Orders();
            int id = Int32.Parse(Request.QueryString["id"]);
            o = oBO.selectOrderById(id);

            txtOrderID.Text = o.OrdersID.ToString();
            txtCusID.Text = o.CustomerID.ToString();
            txtSubId.Text = o.SubCategoryID.ToString();
            txtDate.Text = o.CreateDate.ToString();
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            o = new Orders();
            o.OrdersID = Int32.Parse(txtOrderID.Text);
            o.CustomerID = Int32.Parse(txtCusID.Text);
            o.SubCategoryID = Int32.Parse(txtSubId.Text);
            o.CreateDate = txtDate.Text;
            if (oBO.updateOrder(o))
            {
                Response.Redirect("DanhSachHoaDon.aspx");
            }
        }
    }
}